package com.sfc.sdsr.server.commands;

import com.sfc.sdsr.common.model.Person;
import com.sfc.sdsr.server.ClientData;
import com.sfc.sdsr.server.dao.DaoFactory;

public class CreateMember extends Command {

	private Person newPerson;
	
	public CreateMember(ClientData clientData) {
		dao = DaoFactory.getDao();
		if (clientData.getOperationParameter() instanceof Person) {
			newPerson = (Person) clientData.getOperationParameter();
		} else {
			log.error("Can't create new member. Client Data corrupted, no Person found to Create");
			shouldExecute = false;
			returnObject = null;
		}
	}

	@Override
	public void execute() {
		log.info("Creating Member");
	    returnObject = dao.createMember(newPerson);
	}

}
